#ifndef __ATCLIENT_H_
#define __ATCLIENT_H_

#include <stdint.h>

typedef struct 
{
    /* response buffer */
    char *buf;
    /* the maximum response buffer size, it set by `at_create_resp()` function */
    uint16_t buf_size;
    /* the length of current response buffer */
    uint16_t buf_len;
    /* the number of setting response lines, it set by `at_create_resp()` function
     * == 0: the response data will auto return when received 'OK' or 'ERROR'
     * != 0: the response data will return when received setting lines number data */
    uint8_t line_num;
    /* the count of received response lines */
    uint8_t line_counts;
    /* the maximum response time */
    uint32_t timeout;
}at_response_s;

typedef struct 
{
    const char *cmd_prefix;             // URC prefix
    const char *cmd_suffix;             // URC suffix
    void (*func)(char *data, uint16_t size);     // URC doing function
}at_urc_s;

typedef struct {
 
    uint8_t  debug;
    at_response_s *rsp ;

    void (*delay_ms)(uint32_t); //sleep comeback
    void (*callback_rset)(void);
	void (*at_urc_process)(at_urc_s *at_urc_t);

    void (*write)(at_response_s *at_response ,uint8_t *,uint16_t); //write data to uart function
    int (*read)(at_response_s *at_response);                       //read data from uart function

} at_client_s;

at_response_s* at_resp_set_info(at_response_s* resp, uint16_t buf_size, uint8_t line_num, uint32_t timeout);
at_response_s* at_create_resp(uint16_t buf_size, uint8_t line_num, uint32_t timeout);
void at_delete_resp(at_response_s *resp);
int at_obj_exec_cmd(at_client_s *client, at_response_s *resp, const char *cmd_expr, ...);
int at_readParsing(at_response_s *resp,char *expectRespond);
char *at_rspReadLine(at_response_s *resp,uint8_t resp_line);
#endif

